<template>
  <div style="padding: 10px; height: 750px">
    <a-breadcrumb
      style="font-size: 18px; font-weight: bold; margin-bottom: 20px"
    >
      <a-breadcrumb-item>能源管理</a-breadcrumb-item>
      <a-breadcrumb-item>创建能源</a-breadcrumb-item>
    </a-breadcrumb>
    <div style="margin-top: 50px">
      <a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
        <a-form-item label="能源名称">
          <a-input
            v-model:value="newEnergy.energy_name"
            placeholder="请输入能源名称"
          />
        </a-form-item>
        <a-form-item label="能源单位">
          <a-input
            v-model:value="newEnergy.energy_unit"
            placeholder="请输入能源单位"
          />
        </a-form-item>
        <a-form-item label="发行商 ">
          <a-input
            v-model:value="newEnergy.publisher"
            placeholder="请输入发行商"
          />
        </a-form-item>
        <a-form-item label="能源精度" placeholder="请输入1 ~ 100的数字">
          <a-input
            id="inputNumber"
            v-model:value="newEnergy.energy_acc"
            style="width: 100%"
            placeholder="请输入1 ~ 100的数字"
          />
        </a-form-item>
      </a-form>
      <div style="margin: 20px" align="center">
        <a-button type="primary" @click="submit()">提交</a-button>&nbsp;
      </div>
    </div>
  </div>
</template>
<script setup>
import { defineComponent, ref, reactive } from "vue";
import { get, post, tip } from "@/common";
import { Modal, message } from "ant-design-vue";

const newEnergy = reactive({
  energy_name: "",
  energy_unit: "",
  publisher: "",
  energy_acc: "",
});

const submit = () => {
  if (
    newEnergy.energy_name == "" ||
    newEnergy.energy_unit == "" ||
    newEnergy.energy_acc == "" ||
    newEnergy.publisher == ""
  ) {
    message.warn("信息不能为空！");
  } else {
    post("manager/energy/create", newEnergy).then((res) => {
      newEnergy.energy_name = "";
      newEnergy.energy_unit = "";
      newEnergy.energy_acc = 1;
      newEnergy.publisher = "";
      message.success(res.message);
    });
  }
};
</script>